import { createRouter, createWebHashHistory } from 'vue-router'
import axios from 'axios'

const routes = [
  {
    path: '/',
    name: 'Login',
    component: () => import('../views/Login/index.vue'),
  },
  {
    path: '/park/detail',
    name: 'ParkDetail',
    component: () => import('../views/Park/detail.vue'),
  },
  {
    path: '/firm/detail',
    name: 'FirmDetail',
    component: () => import('../views/Park/firm.vue'),
  },
  {
    path: '/details',
    name: 'details',
    component: () => import('../views/nav/details.vue'),
  },
  {
    path: '/tab',
    name: 'tab',
    component: () => import('../views/nav/tab.vue'),
  },
  {
    path: '/service',
    name: 'service',
    component: () => import('../views/nav/service.vue'),
  },
  {
    path: '/serviceitem',
    name: 'serviceitem',
    component: () => import('../views/nav/serviceitem.vue'),
  },
  {
    path: '/iframe',
    name: 'Iframe',
    component: () => import('@/views/iframe/index.vue'),
  },
  {
    path: '/activity',
    name: 'activity',
    component: () => import('@/views/nav/activity.vue'),
  },
  {
    path: '/find',
    name: 'find',
    component: () => import('@/views/nav/find.vue'),
  },
  {
    path: '/cs',
    name: 'cs',
    component: () => import('@/views/nav/cs.vue'),
  },
  {
    path: '/law',
    name: 'law',
    component: () => import('@/views/nav/law.vue'),
  },
  {
    path: '/lawitem',
    name: 'lawitem',
    component: () => import('@/views/nav/lawitem.vue'),
  },
  {
    path: '/cs',
    name: 'cs',
    component: () => import('@/views/nav/cs.vue'),
  },
  {
    path: '/trends',
    name: 'trends',
    component: () => import('@/views/nav/trends.vue'),
  },
  {
    path: '/search',
    name: 'search',
    component: () => import('@/views/nav/search.vue'),
  },
]

const router = createRouter({
  history: createWebHashHistory(),
  routes,
})

router.beforeEach((to, from, next) => {
  console.log(to)
  //百度统计
  if (to.path) {
    if (window._hmt) {
      window._hmt.push(['_trackPageview', '/#' + to.fullPath])
    }
    // if (window.srt) {
    //   window.srt.track({ title }, { url: to.path })
    // }
  }

  // let islogin = localStorage.getItem('islogin')
  // // 1. 判断是不是登录页面
  // // 是登录页面
  // if (to.path === '/login') {
  //   next()
  // } else {
  //   // 不是登录页面
  //   // 2. 判断 是否登录过
  //   islogin ? next() : next('/login')
  // }
  next()
  //  if (to.path === '/') {
  //     next()
  //  }else if(islogin == 'true' && to.path !== '/login'){
  //   to.path === '/' ? next('/') : next()
  // }else if(islogin == 'false') {
  //   next()
  // }
})

export default router
